package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.entity.Result;
import com.itheima.pojo.Personnel;
import com.itheima.service.StatisticsService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/statistics")
public class StatisticsController {
      //添加企业人员统计
    @Reference
    private StatisticsService statisticsService;
    @RequestMapping("/submit")
    public Result submit(@RequestBody Personnel personnel){
        try {
            statisticsService.save(personnel);
            return new Result(true, MessageConstant.ADD_PERSONNEL_SUCCESS);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.ADD_PERSONNEL_FAIL);
        }
    }
}
